<template>
  <div class="base-container" id="main">
    <t-steps :current="activeForm" status="process" :onChange="onCurChanged">
      <t-step-item title="基本信息" :content="isSubmit('platformId')">
      </t-step-item>
      <t-step-item title="建设单位信息" :content="isSubmit('unitId')"></t-step-item>
      <t-step-item title="立项背景与意义信息" :content="isSubmit('backgroundId')"></t-step-item>
      <t-step-item title="主要任务信息" :content="isSubmit('mainTaskId')"></t-step-item>
      <t-step-item title="经费预算信息" :content="isSubmit('budgetId')"></t-step-item>
      <t-step-item title="仪器设备经费概算信息" :content="isSubmit('equipmentId')"></t-step-item>
      <t-step-item title="委员会人员信息" :content="isSubmit('memberId')"></t-step-item>
      <t-step-item title="建设单位的保障条件与经费配套信息" :content="isSubmit('safeguardId')"></t-step-item>
      <t-step-item title="相关附件" :content="isSubmit('fileId')"></t-step-item>
    </t-steps>
    <t-loading text="加载中..." :fullscreen="false" attach="#main" :loading="applyLoading" size="medium">
    </t-loading>
    <!-- 基本信息 -->
    <t-form ref="form" :key="activeForm" :colon="true" v-if="activeForm === 0" class="step-form" :data="formData0"
            @submit="onSubmit0" :rules="rules0" label-width="180px">
      <t-row style="align-items: stretch" :gutter="14">
        <t-col :span="6">
          <t-card class="step-card" size="small" title="基本信息">
            <t-form-item label="平台名称" name="name">
              <t-input clearable style="width: 390px" v-model="formData0.name"></t-input>
            </t-form-item>
            <t-form-item label="平台当前状态" name="platformStatus">
              <t-select clearable style="width: 390px" v-model="formData0.platformStatus"
                        :options="dict.type.platform_status">
              </t-select>
            </t-form-item>
            <t-form-item label="平台类别" name="platformCategory">
              <t-select clearable style="width: 390px" v-model="formData0.platformCategory"
                        :options="dict.type.platform_category">
              </t-select>
            </t-form-item>
            <t-form-item label="平台级别" name="platformLevel">
              <t-select clearable style="width: 390px" v-model="formData0.platformLevel"
                        :options="dict.type.platform_level">
              </t-select>
            </t-form-item>
            <t-form-item help="手输支持自定义创建" label="关键词" name="keyWord">
              <t-select
                v-model="formData0.keyWord"
                creatable
                filterable
                multiple
                placeholder="手输支持自定义创建"
                :options="dict.type.tjpt_key_word"
                style="width: 390px;"
                @create="createKeyWordOptions"
              >
              </t-select>
            </t-form-item>
            <t-form-item label="研究方向" name="researchDirection">
              <t-select clearable style="width: 390px" v-model="formData0.researchDirection"
                        :options="dict.type.research_direction">
              </t-select>
            </t-form-item>
            <t-form-item label="地址" name="address">
              <t-input clearable style="width: 390px" v-model="formData0.address"></t-input>
            </t-form-item>
            <t-form-item label="邮编" name="postCode">
              <t-input clearable style="width: 390px" v-model="formData0.postCode"></t-input>
            </t-form-item>
            <t-form-item label="立项时间" name="buildDate">
              <t-date-picker clearable style="width: 390px" v-model="formData0.buildDate"></t-date-picker>
            </t-form-item>
            <t-form-item label="网址" name="website">
              <t-input clearable style="width: 390px" v-model="formData0.website"></t-input>
            </t-form-item>
            <t-form-item label="平台建设内容" name="content">
              <t-textarea style="width: 390px" clearable tips="不超过200字" :maxlength="200" :autosize="{ minRows: 3 }"
                          v-model="formData0.content"
                          placeholder="请输入内容"/>
            </t-form-item>
          </t-card>
        </t-col>
        <t-col :span="6">
          <t-card class="step-card" size="small" title="平台联系人">
            <t-form-item label="姓名" name="platformLinker.name">
              <t-select
                v-model="formData0.platformLinker.name"
                creatable
                filterable
                @change="onLeaderNameChange2"
                placeholder="请输入姓名"
                :loading="leaderLoading2"
                @search="remoteProjectLeaderMethod2"
                :options="nameOptions2"
                @create="createProjectLeaderOptions2"
                style="width: 390px"
              />
              <!--                    <t-input style="width: 390px" clearable v-model="formData0.platformLinker.name"></t-input>-->
            </t-form-item>
            <t-form-item label="联系电话" name="platformLinker.telephone">
              <t-input style="width: 390px" placeholder="请输入电话号码" clearable
                       v-model="formData0.platformLinker.telephone"></t-input>
            </t-form-item>
            <t-form-item label="手机号码" name="platformLinker.phone">
              <t-input style="width: 390px" placeholder="请输入手机号码" clearable
                       v-model="formData0.platformLinker.phone"></t-input>
            </t-form-item>
            <t-form-item label="电子信箱" name="platformLinker.email">
              <t-input style="width: 390px" clearable v-model="formData0.platformLinker.email"></t-input>
            </t-form-item>
            <t-form-item label="传真" name="platformLinker.facsimile">
              <t-input style="width: 390px" clearable v-model="formData0.platformLinker.facsimile"></t-input>
            </t-form-item>
          </t-card>
        </t-col>
      </t-row>
      <t-row style="align-items: stretch" :gutter="14">
        <t-col :span="12">
          <t-card class="step-card" size="small" title="平台负责人">
            <t-row>
              <t-col :span="6">
                <!--                  <t-form-item label="姓名" name="platformLeader.name">-->
                <!--                    <t-input style="width: 390px" clearable v-model="formData0.platformLeader.name"></t-input>-->
                <!--                  </t-form-item>-->
                <t-form-item label="姓名" name="platformLeader.name">
                  <t-select
                    v-model="formData0.platformLeader.name"
                    creatable
                    filterable
                    @change="onLeaderNameChange"
                    placeholder="请输入姓名"
                    :loading="leaderLoading"
                    @search="remoteProjectLeaderMethod"
                    :options="nameOptions"
                    @create="createProjectLeaderOptions"
                    style="width: 390px"
                  />
                </t-form-item>
                <t-form-item label="性别" name="platformLeader.sex">
                  <t-select style="width: 390px" placeholder="请选择性别" :options="dict.type.sys_user_sex"
                            v-model="formData0.platformLeader.sex">
                  </t-select>
                </t-form-item>
                <t-form-item label="身份证号" name="platformLeader.idCard">
                  <t-input style="width: 390px" placeholder="请输入身份证号" clearable
                           v-model="formData0.platformLeader.idCard"></t-input>
                </t-form-item>
                <t-form-item label="出生年月" name="platformLeader.birthDate">
                  <t-date-picker placeholder="请选择生日" v-model="formData0.platformLeader.birthDate" :disable-date="{
                      after: dayjs().endOf('month').add(-18, 'year').format()
                    }" style="width: 390px"></t-date-picker>
                </t-form-item>
                <t-form-item label="联系电话" name="platformLeader.telephone">
                  <t-input style="width: 390px" placeholder="请输入电话号码" clearable
                           v-model="formData0.platformLeader.telephone"></t-input>
                </t-form-item>
                <t-form-item label="手机号码" name="platformLeader.phone">
                  <t-input style="width: 390px" placeholder="请输入手机号码" clearable
                           v-model="formData0.platformLeader.phone"></t-input>
                </t-form-item>
                <t-form-item label="电子信箱" name="platformLeader.email">
                  <t-input style="width: 390px" clearable v-model="formData0.platformLeader.email"></t-input>
                </t-form-item>
              </t-col>
              <t-col :span="6">
                <t-form-item label="学历" name="platformLeader.education">
                  <t-select style="width: 390px" v-model="formData0.platformLeader.education" clearable
                            placeholder="请选择学历" :options="dict.type.education">
                  </t-select>
                </t-form-item>
                <t-form-item label="专业" name="platformLeader.majorName">
                  <t-input
                    v-model="formData0.platformLeader.majorName"
                    clearable
                    placeholder="请输入专业"
                    style="width: 390px"
                  />
                </t-form-item>
                <t-form-item label="职务" name="platformLeader.duty">
                  <t-input style="width: 390px" clearable v-model="formData0.platformLeader.duty"></t-input>
                </t-form-item>
                <t-form-item label="技术职称" name="platformLeader.profTitId">
                  <t-tree-select clearable @change="onProfTitIdChange" filterable style="width: 390px"
                                 :treeProps="{ keys: { value: 'id' }, valueMode: 'onlyLeaf' }" v-model="formData0.platformLeader.profTitId"
                                 :data="profTitOptions" placeholder="职称"></t-tree-select>
                  <!--                    <t-input style="width: 390px" clearable v-model="formData0.projectLeader.profTitId"-->
                  <!--                    ></t-input>-->
                </t-form-item>
                <t-form-item label="职称" name="platformLeader.profTit">
                  <t-select disabled style="width: 390px" v-model="formData0.platformLeader.profTit" clearable
                            placeholder="请选择职称" :options="dict.type.prof_tit">
                  </t-select>
                </t-form-item>
              </t-col>
            </t-row>
          </t-card>
        </t-col>
      </t-row>
      <t-row>
        <t-col :span="11" class="query-form-inline">
          <t-button v-if="!getPlatformId" theme="primary" type="submit">提交申请</t-button>
          <t-button v-else theme="primary" type="submit">下一步</t-button>
        </t-col>
        <t-col :span="1" class="operation-container">
          <t-button variant="outline" @click="close">返回</t-button>
        </t-col>
      </t-row>
    </t-form>
    <!-- 建设单位信息 -->
    <t-form ref="form" :key="activeForm" :colon="true" labelAlign="top" v-if="activeForm === 1" class="step-form"
            :data="formData1" @submit="onSubmit1" :rules="rules1" labelWidth="180px">
      <t-row style="align-items:stretch" :gutter="14">
        <t-col :span="12">
          <t-card class="step-card" size="small" title="建设单位信息">
            <t-row>
              <t-col :span="6">
                <t-form-item label="建设单位" name="unitId">
                  <t-tree-select clearable filterable style="width: 390px" :treeProps="{ keys: { value: 'id' } }"
                                 v-model="formData1.unitId" :data="deptMenuOptions"
                                 placeholder="选择建设单位"></t-tree-select>
                </t-form-item>
                <t-form-item label="分管领导-姓名" name="name">
                  <t-select
                    v-model="formData1.name"
                    creatable
                    filterable
                    @change="onLeaderNameChange3"
                    placeholder="请输入姓名"
                    :loading="leaderLoading3"
                    @search="remoteProjectLeaderMethod3"
                    :options="nameOptions3"
                    @create="createProjectLeaderOptions3"
                    style="width: 390px"
                  />
                  <!--                    <t-input style="width: 390px" clearable v-model="formData1.name"></t-input>-->
                </t-form-item>
                <t-form-item label="性别" name="sex">
                  <t-select style="width: 390px" placeholder="请选择性别" :options="dict.type.sys_user_sex"
                            v-model="formData1.sex">
                  </t-select>
                </t-form-item>
                <t-form-item label="身份证号" name="idCard">
                  <t-input style="width: 390px" placeholder="请输入身份证号" clearable
                           v-model="formData1.idCard"></t-input>
                </t-form-item>
                <t-form-item label="出生年月" name="birthDate">
                  <t-date-picker mode="month" placeholder="请选择生日" v-model="formData1.birthDate" :disable-date="{
                      after: dayjs().endOf('month').add(-18, 'year').format()
                    }" style="width: 390px"></t-date-picker>
                </t-form-item>
                <t-form-item label="学历" name="education">
                  <t-select style="width: 390px" v-model="formData1.education" clearable placeholder="请选择学历"
                            :options="dict.type.education">
                  </t-select>
                </t-form-item>
                <t-form-item label="职务" name="duty">
                  <t-input style="width: 390px" clearable v-model="formData1.duty"></t-input>
                </t-form-item>
                <t-form-item label="技术职称" name="profTitId">
                  <t-tree-select clearable @change="onProfTitIdChange2" filterable style="width: 390px"
                                 :treeProps="{ keys: { value: 'id' }, valueMode: 'onlyLeaf' }" v-model="formData1.profTitId"
                                 :data="profTitOptions"
                                 placeholder="职称"></t-tree-select>
                </t-form-item>
                <t-form-item label="职称" name="profTit">
                  <t-select disabled style="width: 390px" v-model="formData1.profTit" clearable placeholder="请选择职称"
                            :options="dict.type.prof_tit">
                  </t-select>
                </t-form-item>
                <t-form-item label="专业" name="majorName">
                  <t-input
                    v-model="formData1.majorName"
                    clearable
                    placeholder="请输入专业"
                    style="width: 390px"
                  />
                </t-form-item>
              </t-col>
              <t-col :span="6">
                <t-form-item label="联系电话" name="telephone">
                  <t-input style="width: 390px" placeholder="请输入电话号码" clearable
                           v-model="formData1.telephone"></t-input>
                </t-form-item>
                <t-form-item label="手机号码" name="phone">
                  <t-input style="width: 390px" placeholder="请输入手机号码" clearable
                           v-model="formData1.phone"></t-input>
                </t-form-item>
                <t-form-item label="电子信箱" name="email">
                  <t-input style="width: 390px" clearable v-model="formData1.email"></t-input>
                </t-form-item>
                <t-form-item label="科技管理部门名称" name="deptName">
                  <t-input style="width: 390px" clearable v-model="formData1.deptName"></t-input>
                </t-form-item>
                <t-form-item label="科技管理部门电话" name="deptTelephone">
                  <t-input style="width: 390px" clearable v-model="formData1.deptTelephone"></t-input>
                </t-form-item>
                <t-form-item label="科技管理部门传真" name="deptFacsimile">
                  <t-input style="width: 390px" clearable v-model="formData1.deptFacsimile"></t-input>
                </t-form-item>
                <t-form-item label="科技管理部地址" name="deptAddress">
                  <t-input style="width: 390px" clearable v-model="formData1.deptAddress"></t-input>
                </t-form-item>
                <t-form-item label="科技管理部门邮编" name="deptPostCode">
                  <t-input style="width: 390px" clearable v-model="formData1.deptPostCode"></t-input>
                </t-form-item>
              </t-col>
            </t-row>
          </t-card>
        </t-col>
      </t-row>
      <t-row>
        <t-col :span="11" class="query-form-inline">
          <t-button @click="onCurChanged(0)" theme="default" variant="base">上一步</t-button>
          <t-button theme="primary" type="submit">下一步</t-button>
        </t-col>
        <t-col :span="1" class="operation-container">
          <t-button variant="outline" @click="close">返回</t-button>
        </t-col>
      </t-row>
    </t-form>
    <!-- 立项背景与意义信息 -->
    <t-form ref="form" :key="activeForm" :colon="true" labelAlign="top" v-if="activeForm === 2" class="step-form"
            :data="formData2" @submit="onSubmit2" :rules="rules2">
      <t-form-item label="立项背景与意义:" name="background">
        <tiny-mce-editor :key="activeForm" :maxlength="2000" :textLength.sync="lengthLimitObj.background"
                         v-model="formData2.background"></tiny-mce-editor>
      </t-form-item>
      <t-row>
        <t-col :span="11" class="query-form-inline">
          <t-button @click="onCurChanged(1)" theme="default" variant="base">上一步</t-button>
          <t-button theme="primary" type="submit">下一步</t-button>
        </t-col>
        <t-col :span="1" class="operation-container">
          <t-button variant="outline" @click="close">返回</t-button>
        </t-col>
      </t-row>
    </t-form>
    <!-- 主要任务信息 -->
    <t-form ref="form" :key="activeForm" :colon="true" labelAlign="top" v-if="activeForm === 3" class="step-form"
            :data="formData3" @submit="onSubmit3" :rules="rules3">
      <t-form-item label="主要任务信息:" name="mainTask">
        <tiny-mce-editor :key="activeForm" :textLength.sync="lengthLimitObj.mainTask"
                         v-model="formData3.mainTask"></tiny-mce-editor>
      </t-form-item>
      <t-row>
        <t-col :span="11" class="query-form-inline">
          <t-button @click="onCurChanged(2)" theme="default" variant="base">上一步</t-button>
          <t-button theme="primary" type="submit">下一步</t-button>
        </t-col>
        <t-col :span="1" class="operation-container">
          <t-button variant="outline" @click="close">返回</t-button>
        </t-col>
      </t-row>
    </t-form>
    <!-- 经费预算信息 -->
    <div class="step-form" v-if="activeForm === 4">
      <t-row style="align-items: stretch" :gutter="14">
        <t-col :span="12">
          <platform-budget v-model="formData4" :fundingObj="fundingObj" :platformId="getPlatformId()" :editOpen="true"
                           phaseType="1"></platform-budget>
        </t-col>
      </t-row>
      <t-row>
        <t-col :span="11" class="query-form-inline">
          <t-button  @click="onCurChanged(3)" theme="primary" variant="base">上一步
          </t-button>
          <t-button theme="primary" @click="onSubmit4()" type="submit">下一步</t-button>
        </t-col>
        <t-col :span="1" class="operation-container">
          <t-button variant="outline" @click="close">返回</t-button>
        </t-col>
      </t-row>
    </div>
    <!-- 仪器设备经费概算信息 -->
    <t-form ref="form" :key="activeForm" :colon="true" labelAlign="top" v-if="activeForm === 5" class="step-form"
            :data="formData5" @submit="onSubmit5" :rules="rules5">
      <t-form-item label="仪器设备:" name="Equipments">
        <platform-background-literature ref="project-background-literature"
                                        v-model="formData5.Equipments" :editOpen="true"
                                        :value="formData5.Equipments"></platform-background-literature>
      </t-form-item>
      <t-row>
        <t-col :span="11" class="query-form-inline">
          <t-button @click="onCurChanged(4)" theme="default" variant="base">上一步</t-button>
          <t-button theme="primary" type="submit">下一步</t-button>
        </t-col>
        <t-col :span="1" class="operation-container">
          <t-button variant="outline" @click="close">返回</t-button>
        </t-col>
      </t-row>
    </t-form>
    <!-- 委员会人员信息-->
    <t-form ref="form" :key="activeForm" :colon="true" labelAlign="top" v-if="activeForm === 6" class="step-form"
            :data="formData8" @submit="onSubmit8" :rules="rules8">
      <t-form-item label="专家人员信息" name="platformMember">
        <platform-member ref="platform-member" v-model="formData8.platformMember" :dict-types="dictTypes"
                         :editOpen="true" class="description"></platform-member>
      </t-form-item>
      <t-form-item label="技术人员信息" name="platformMemberTechnology">
        <platform-member-technology ref="platform-member-technology" v-model="formData8.platformMemberTechnology"
                                    :dict-types="dictTypes"
                                    :editOpen="true" class="description"></platform-member-technology>
      </t-form-item>
      <t-row>
        <t-col :span="11" class="query-form-inline">
          <t-button @click="onCurChanged(5)" theme="default" variant="base">上一步</t-button>
          <t-button theme="primary" type="submit">下一步</t-button>
        </t-col>
        <t-col :span="1" class="operation-container">
          <t-button variant="outline" @click="close">返回</t-button>
        </t-col>
      </t-row>
    </t-form>
    <!-- 建设单位的保障条件与经费配套信息 -->
    <t-form ref="form" :key="activeForm" :colon="true" labelAlign="top" v-if="activeForm === 7" class="step-form"
            :data="formData7" @submit="onSubmit7(1)" :rules="rules7">
      <t-form-item label="建设单位的保障条件与经费配套" name="safeguardCondition">
        <tiny-mce-editor :key="activeForm" :maxlength="2000" :textLength.sync="lengthLimitObj.safeguardCondition"
                         v-model="formData7.safeguardCondition"></tiny-mce-editor>
      </t-form-item>
      <t-row>
        <t-col :span="11" class="query-form-inline">
          <t-button @click="onCurChanged(6)" theme="default" variant="base">上一步</t-button>
          <t-button theme="primary" type="submit">下一步</t-button>
        </t-col>
        <t-col :span="1" class="operation-container">
          <t-button variant="outline" @click="close">返回</t-button>
        </t-col>
      </t-row>
    </t-form>
    <!--     附件-->
    <t-form ref="form" :key="activeForm" :colon="true" labelAlign="top" v-if="activeForm === 8" class="step-form"
            :data="formData7">
      <t-form-item name="fileUpload" label="上传申报相关文件" labelAlign="top" style="margin-bottom: 10px">
        <t-table row-key="id" :columns="projectFileColumns" :data="projectFileData">
          <template #id="{row, rowIndex}">
            {{ rowIndex+1 }}
          </template>
          <template #op="{row}">
            <file-upload tips="限制pdf、图片"  accept="application/pdf,image/*" v-model="row.fileIds" :moduleKey="row.moduleKey"
                         :fileList="row.fileLists"
                         :multiple="true " >
              <t-button variant="outline">
                <t-icon name="cloud-upload" slot="icon"/>
                点击上传
              </t-button>
            </file-upload>
          </template>
          <template #c1="{row}">
            <a v-if="row.c3" class="t-button-link" :href="`${file_domain}/${row.c3}`" target="_blank">{{ row.c1 }}</a>
            <div v-else>{{ row.c1 }}</div>
          </template>
        </t-table>
      </t-form-item>
      <t-row>
        <t-col :span="11" class="query-form-inline">
          <t-button :disabled="isCommit" type="reset" @click="onCurChanged(7)" theme="default" variant="base">上一步
          </t-button>
          <!--          <t-button :disabled="isCommit" theme="primary" @click="onSubmit7(1)" type="submit">暂存</t-button>-->
          <t-tooltip content="提交后不可再编辑会进入审批流程">
            <t-button :disabled="isCommit" theme="primary" @click="onSubmit9()" type="submit">提交</t-button>
          </t-tooltip>
        </t-col>
        <t-col :span="1" class="operation-container">
          <t-button variant="outline" @click="close">返回</t-button>
        </t-col>
      </t-row>
    </t-form>
  </div>
</template>

<script>
import { VITE_FILE_DOMAIN } from '@/api/upload'
import TinyMceEditor from "@/components/TinyMceEditor/index.vue";
import PlatformBackgroundLiterature from "./components/platform-background-literature.vue";
import platformBudget from "@/pages/tjpt/platform/components/platform-budget.vue";
import platformMember from "@/pages/tjpt/components/platform-member.vue";
import platformMemberTechnology from "@/pages/tjpt/components/platform-member-technology.vue";
import FileUpload from "@/components/FileUpload/index.vue"
import {TODAY} from '@/utils/date';
import dayjs from "dayjs";
import {getDictList} from "@/api/system/dict/data";
import {getFiles} from "@/api/common";

export default {
  name: "platform-apply",
  dicts: ["platform_status", "platform_category", "tjpt_key_word", "project_type", "subject_classification", "sys_user_sex", "prof_tit", "degree", "education", "duty", "platform_type", "expect_result_type", "platform_level", "research_direction"],
  components: {
    TinyMceEditor,
    PlatformBackgroundLiterature,
    platformBudget,
    platformMember,
    platformMemberTechnology,
    FileUpload
  },
  data() {
    return {
      projectFileData: [
        {
          id: 1,
          c1: "批复文件",
          c2: "否",
          moduleKey: "platformPFWJ",
          fileIds: [],
          fileLists: [],
        },
      ],
      projectFileColumns: [
        {
          colKey: "id",
          title: "序号",
          align: "center",
          width: 64
        },
        {
          colKey: "c1",
          title: "附件名称",
          align: "center",
        },

        {
          colKey: "c2",
          title: "是否必需",
          align: "center",
        },
        {
          colKey: "op",
          title: "操作",
          align: "left",
        },
      ],
      dictTypes: {},
      applyLoading: false,
      keyWord: [],
      nameOptions: [],
      nameOptions2: [],
      nameOptions3: [],
      leaderLoading: false,
      leaderLoading2: false,
      leaderLoading3: false,
      maxlength: 1000,
      lengthLimitObj: {
        safeguardCondition: 0,
        background: 0,
        researchContent: 0,
        achievement: 0,
        mainTask: 0
      },
      fundingObj: {subsidyFunding: 0, adviceFunding: 0},
      disableDate: {},
      adviceFunding: 0,
      subsidyFunding: 0,
      tinymceFlag: 1,
      oldUser: null,
      dayjs,
      site_tag: import.meta.env.VITE_SITE_TAG,
      file_domain: VITE_FILE_DOMAIN,
      projectCategoryColumns: [
        {
          colKey: "name",
          title: "类别名称",
        },
        {
          colKey: 'row-select',
          type: 'single',
          title: "选择",
          width: 64,
          checkProps: ({row}) => ({disabled: row.children && row.children.length > 0}),
        },
        {
          colKey: "categoryType",
          title: "类型",
          align: "center",
          width: 100
        },
        {
          colKey: "startDate",
          title: "申报开始时间",
          align: "center",
          width: 200
        },
        {
          colKey: "endDate",
          title: "申报结束时间",
          align: "center",
          width: 200
        },
        {
          colKey: "applyStatus",
          title: "申报状态",
          align: "center",
          width: 200
        },
        {
          colKey: 'note',
          title: "描述",
          ellipsis: true
        },
      ],
      // projectFileData: [
      //   {
      //     id: 1,
      //     c1: "查新报告",
      //     c2: "是",
      //     moduleKey: "projectCXBG",
      //     fileIds: [],
      //     fileLists: [],
      //   },
      //   {
      //     id: 2,
      //     c1: "归口管理单位科研诚信承诺书",
      //     c2: "是",
      //     fileIds: [],
      //     fileLists: [],
      //     moduleKey: "projectCNS"
      //   },
      //   {
      //     id: 3,
      //     c1: "项目组科研诚信承诺书",
      //     c2: "是",
      //     fileIds: [],
      //     fileLists: [],
      //     moduleKey: "projectTeamCNS"
      //   }
      // ],
      // projectFileColumns: [
      //   {
      //     colKey: "id",
      //     title: "序号",
      //     align: "center",
      //     width: 64
      //   },
      //   {
      //     colKey: "c1",
      //     title: "附件名称",
      //     align: "center",
      //   },
      //   {
      //     colKey: "c2",
      //     title: "是否必需",
      //     align: "center",
      //   },
      //   {
      //     colKey: "op",
      //     title: "操作",
      //     align: "left",
      //   },
      // ],
      selectedProjectCategoryRowKeys: [],
      isCommit: false,
      profTitOptions: [],
      menuOptions: [],
      deptMenuOptions: [],
      // selectedResearchPlanRowKeys: [],
      selectedUnitRowKeys: [],
      selectedMemberRowKeys: [],
      selectedMember1RowKeys: [],
      formData7: {
        safeguardCondition: ""
      },
      formData8: {
        "platformMember": [],
        "platformMemberTechnology": []
      },
      data8: [],
      columns7: [],
      columns9: [],
      data3: [],
      data7: [],
      taskId: null,
      tabValue: "0",
      activeForm: null,
      wordData: 0,
      formData1: {
        unitId: null,
        name: '',
        sex: '',
        birthDate: '',
        education: '',
        duty: '',
        profTitId: null,
        profTit: '',
        majorName: '',
        telephone: '',
        phone: '',
        email: '',
        deptName: '',
        deptTelephone: '',
        deptFacsimile: '',
        deptAddress: '',
        deptPostCode: "",
        platformId: null,
        idCard: ""
      },
      rules1: {
        'unitId': [
          {
            required: true,
            message: "建设单位不能为空",
          },
        ],
        'name': [
          {
            required: true,
            message: "姓名不能为空",
          },
        ],
        'sex': [
          {
            required: true,
            message: "性别不能为空",
          },
        ],
        'birthDate': [
          {
            required: true,
            message: "生日不能为空",
          },
        ],
        'education': [
          {
            required: true,
            message: "学历不能为空",
          },
        ],
        'duty': [
          {
            required: true,
            message: "职务不能为空",
          },
        ],
        'profTitId': [
          {
            required: true,
            message: "职称不能为空",
          },
        ],
        'profTit': [
          {
            required: true,
            message: "职称名字不能为空",
          },
        ],
        'majorName': [
          {
            required: true,
            message: "所学专业不能为空",
          },
        ],
        'telephone': [
          {
            required: true,
            message: "联系电话不能为空",
          },
          {
            pattern: /^1[3|4|5|6|7|8|9][0-9]\d{8}$/,
            message: "联系电话请输入正确的手机号码",
          },
        ],
        "idCard": [
          {
            required: true,
            message: "身份证不能为空",
          },
          {
            message: "身份证号不正确",
            pattern: /^\d{6}((((((19|20)\d{2})(0[13-9]|1[012])(0[1-9]|[12]\d|30))|(((19|20)\d{2})(0[13578]|1[02])31)|((19|20)\d{2})02(0[1-9]|1\d|2[0-8])|((((19|20)([13579][26]|[2468][048]|0[48]))|(2000))0229))\d{3})|((((\d{2})(0[13-9]|1[012])(0[1-9]|[12]\d|30))|((\d{2})(0[13578]|1[02])31)|((\d{2})02(0[1-9]|1\d|2[0-8]))|(([13579][26]|[2468][048]|0[048])0229))\d{2}))(\d|X|x)$/,
          },
        ],
        'phone': [
          {
            required: true,
            message: "联系手机号码不能为空",
          },
          {
            pattern: /^1[3|4|5|6|7|8|9][0-9]\d{8}$/,
            message: "联系电话请输入正确的手机号码",
          },
        ],
        'email': [
          {
            required: true,
            message: "邮箱不能为空",
          },
          {email: {ignore_max_length: true}, message: '请输入正确的邮箱地址'}
        ],
        'deptName': [
          {
            required: true,
            message: "科技管理部门名称不能为空",
          },
        ],
        'deptTelephone': [
          {
            required: true,
            message: "科技管理部门电话不能为空",
          },
          {
            pattern: /^1[3|4|5|6|7|8|9][0-9]\d{8}$/,
            message: "联系电话请输入正确的手机号码",
          },
        ],
        'deptFacsimile': [
          {
            required: true,
            message: "科技管理部门传真不能为空",
          },
        ],
        'deptAddress': [
          {
            required: true,
            message: "科技管理部地址不能为空",
          },
        ],
        'deptPostCode': [
          {
            required: true,
            message: "科技管理部门邮编不能为空",
          },
        ],
      },
      formData0: {
        keyWord: '',
        keyWordList: [],
        platformLevel: "",
        researchDirection: "",
        name: '',
        platformCategory: '',
        address: "",
        postCode: "",
        buildDate: TODAY,
        website: "",
        content: "",
        platformStatus: 1, // 暂存传1，提交传2
        platformLeader: {
          name: '',
          sex: '',
          birthDate: '',
          telephone: '',
          idCard: "",
          phone: "",
          email: '',
          education: '',
          majorName: '',
          duty: '',
          profTitId: '',
          profTit: '',
        },
        platformLinker: {
          name: '',
          phone: '',
          email: '',
          telephone: '',
          facsimile: '',
        },
      },
      rules0: {
        // 基本信息
        keyWord: [{required: true, validator: (val) => val && val.length, message: "关键词不能为空", type: "error"}],
        name: [
          {
            required: true,
            message: "平台名称不能为空",
          },
        ],
        platformStatus: [
          {required: true, message: "平台当前状态不能为空", type: "error"}
        ],
        platformCategory: [
          {required: true, message: "平台类别不能为空", type: "error"}
        ],
        platformLevel: [
          {required: true, message: "平台等级不能为空", type: "error"}
        ],
        researchDirection: [
          {required: true, message: "研究方向不能为空", type: "error"}
        ],
        address: [
          {
            required: true,
            message: "地址不能为空",
          },
        ],
        postCode: [
          {
            required: true,
            message: "邮编不能为空",
          },
        ],
        buildDate: [
          {
            required: true,
            message: "立项时间不能为空",
          },

        ],
        website: [
          {
            required: true,
            message: "网址不能为空",
          },
        ],
        content: [
          {
            required: true,
            message: "平台建设内容不能为空",
          },
        ],
        // platformLinker（联系人）
        'platformLinker.name': [
          {
            required: true,
            message: "项目联系人姓名不能为空",
          },
        ],
        'platformLinker.phone': [
          {
            required: true,
            message: "联系人电话不能为空",
          },
          {
            pattern: /^1[3|4|5|6|7|8|9][0-9]\d{8}$/,
            message: "联系人电话请输入正确的手机号码",
          },
        ],
        'platformLinker.telephone': [
          {
            required: true,
            message: "联系人电话不能为空",
          },
          {
            pattern: /^1[3|4|5|6|7|8|9][0-9]\d{8}$/,
            message: "联系人电话请输入正确的手机号码",
          },
        ],
        'platformLinker.email': [
          {
            required: true,
            message: "联系人邮箱不能为空",
          },
          {email: {ignore_max_length: true}, message: '请输入正确的邮箱地址'}
        ],
        'platformLinker.facsimile': [
          {
            required: true,
            message: "联系人传真不能为空",
          },
        ],
        // platformLeader（平台负责人）
        'platformLeader.name': [
          {
            required: true,
            message: "平台负责人姓名不能为空",
          },
        ],
        'platformLeader.sex': [
          {
            required: true,
            message: "平台主要负责人性别不能为空",
          },
        ],
        'platformLeader.idCard': [
          {
            required: true,
            message: "平台主要负责人身份证不能为空",
          },
          {
            message: "身份证号不正确",
            pattern: /^\d{6}((((((19|20)\d{2})(0[13-9]|1[012])(0[1-9]|[12]\d|30))|(((19|20)\d{2})(0[13578]|1[02])31)|((19|20)\d{2})02(0[1-9]|1\d|2[0-8])|((((19|20)([13579][26]|[2468][048]|0[48]))|(2000))0229))\d{3})|((((\d{2})(0[13-9]|1[012])(0[1-9]|[12]\d|30))|((\d{2})(0[13578]|1[02])31)|((\d{2})02(0[1-9]|1\d|2[0-8]))|(([13579][26]|[2468][048]|0[048])0229))\d{2}))(\d|X|x)$/,
          },
        ],
        'platformLeader.birthDate': [
          {
            required: true,
            message: "平台主要负责人生日不能为空",
          },

        ],
        'platformLeader.telephone': [
          {
            required: true,
            message: "平台主要负责人联系电话不能为空",
          },
          {
            pattern: /^1[3|4|5|6|7|8|9][0-9]\d{8}$/,
            message: "请输入正确的手机号码",
          },
        ],
        'platformLeader.phone': [
          {
            required: true,
            message: "平台主要负责人联系手机号码不能为空",
          },
          {
            pattern: /^1[3|4|5|6|7|8|9][0-9]\d{8}$/,
            message: "请输入正确的手机号码",
          },
        ],
        'platformLeader.email': [
          {
            required: true,
            message: "平台主要负责人邮箱不能为空",
          },
          {email: {ignore_max_length: true}, message: '请输入正确的邮箱地址'}
        ],
        'platformLeader.education': [
          {
            required: true,
            message: "平台主要负责人学历不能为空",
          },
        ],
        'platformLeader.majorName': [
          {
            required: true,
            message: "平台主要负责人所学专业不能为空",
          },
        ],
        'platformLeader.profTitId': [
          {
            required: true,
            message: "平台主要负责人职称不能为空",
          },
        ],
        'platformLeader.duty': [
          {
            required: true,
            message: "平台主要负责人职务不能为空",
          },
        ],
        'platformLeader.profTit': [
          {
            required: true,
            message: "平台主要负责人职称名字不能为空",
          },
        ],

      },
      formData2: {
        background: '',
      },
      rules2: {
        background: [
          {
            required: true,
            message: "立项背景与意义不能为空",
          },
        ],
      },
      rules8: {
        platformMember: [
          {
            required: true,
            message: "专家人员信息不能为空",
          },
        ],
        platformMemberTechnology: [
          {
            required: true,
            message: "技术人员信息不能为空",
          },
        ],
      },
      rules5: {
        Equipments: [
          {
            required: true,
            message: "仪器设备不能为空",
          },
        ],
      },
      formData3: {
        mainTask: '',
      },
      rules7: {
        safeguardCondition: [
          {
            required: true,
            message: "建设单位的保障条件与经费配套信息不能为空",
          },
        ],
      },
      rules3: {
        mainTask: [
          {
            required: true,
            message: "主要任务信息不能为空",
          },
        ],
      },
      rules4: {
        inTbBudget: [
          {
            required: true,
            message: "厅拨经费不能为空",
          },
        ],
        inZcBudget: [
          {
            required: true,
            message: "自筹经费不能为空",
          },
        ],
        outTbSbBudget: [
          {
            required: true,
            message: "设备费-厅拨-购置设备费不能为空",
          },
        ],

        outZcSbBudget: [
          {
            required: true,
            message: "设备费-自筹-购置设备费不能为空",
          },
        ],

        outTbSzsbBudget: [
          {
            required: true,
            message: "设备费-厅拨-试制设备费不能为空",
          },
        ],

        outZcSzsbBudget: [
          {
            required: true,
            message: "设备费-自筹-试制设备费不能为空",
          },
        ],

        outTbSbzzBudget: [
          {
            required: true,
            message: "设备费-厅拨-设备改造与租赁费不能为空",
          },
        ],

        outZcSbzzBudget: [
          {
            required: true,
            message: "设备费-自筹-设备改造与租赁费不能为空",
          },
        ],

        outTbClBudget: [
          {
            required: true,
            message: "材料费-厅拨不能为空",
          },
        ],

        outZcClBudget: [
          {
            required: true,
            message: "材料费-自筹不能为空",
          },
        ],

        outTbSyjgBudget: [
          {
            required: true,
            message: "测试化验实验加工费-厅拨不能为空",
          },
        ],

        outZcSyjgBudget: [
          {
            required: true,
            message: "测试化验实验加工费-自筹不能为空",
          },
        ],

        outTbRldlBudget: [
          {
            required: true,
            message: "燃料动力费-厅拨不能为空",
          },
        ],

        outZcRldlBudget: [
          {
            required: true,
            message: "燃料动力费-自筹不能为空",
          },
        ],

        outTbClvBudget: [
          {
            required: true,
            message: "差旅费-厅拨不能为空",
          },
        ],

        outZcClvBudget: [
          {
            required: true,
            message: "差旅费-自筹不能为空",
          },
        ],

        outTbHyBudget: [
          {
            required: true,
            message: "会议费-厅拨不能为空",
          },
        ],

        outZcHyBudget: [
          {
            required: true,
            message: "会议费-自筹不能为空",
          },
        ],

        outTbGjhzBudget: [
          {
            required: true,
            message: "国际合作与交流费-厅拨不能为空",
          },
        ],

        outZcGjhzBudget: [
          {
            required: true,
            message: "国际合作与交流费-自筹不能为空",
          },
        ],

        outTbCbBudget: [
          {
            required: true,
            message: "出版/文献/信息传播/知识产权事务/印刷费-厅拨不能为空",
          },
        ],

        outZcCbBudget: [
          {
            required: true,
            message: "出版/文献/信息传播/知识产权事务/印刷费-自筹不能为空",
          },
        ],

        outTbLwBudget: [
          {
            required: true,
            message: "劳务费-厅拨不能为空",
          },
        ],

        outZcLwBudget: [
          {
            required: true,
            message: "劳务费-自筹不能为空",
          },
        ],

        outTbZjzxBudget: [
          {
            required: true,
            message: "专家咨询费-厅拨不能为空",
          },
        ],

        outZcZjzxBudget: [
          {
            required: true,
            message: "专家咨询费-自筹不能为空",
          },
        ],
        outTbQtBudget: [
          {
            required: true,
            message: "其他支出-厅拨不能为空",
          },
        ],

        outZcQtBudget: [
          {
            required: true,
            message: "其他支出-自筹不能为空",
          },
        ],

        outTbGlBudget: [
          {
            required: true,
            message: "管理费-厅拨不能为空",
          },
        ],

        outZcGlBudget: [
          {
            required: true,
            message: "管理费-自筹不能为空",
          },
        ],

        tbsqyiBudget: [
          {
            required: true,
            message: "第一年金额不能为空",
          },
        ],
        tbsqyibl: [
          {
            required: true,
            message: "第一年比例不能为空",
          },
        ],
        tbsqerBudget: [
          {
            required: true,
            message: "第二年金额不能为空",
          },
        ],
        tbsqerbl: [
          {
            required: true,
            message: "第二年比例不能为空",
          },
        ],
      },
      formData4: {
        platformId: "",
        inTbBudget: "",
        inZcBudget: "",
        outTbSbBudget: "",
        outZcSbBudget: "",
        outTbSzsbBudget: "",
        outZcSzsbBudget: "",
        outTbSbzzBudget: "",
        outZcSbzzBudget: "",
        outTbClBudget: "",
        outZcClBudget: "",
        outTbSyjgBudget: "",
        outZcSyjgBudget: "",
        outTbRldlBudget: "",
        outZcRldlBudget: "",
        outTbClvBudget: "",
        outZcClvBudget: "",
        outTbHyBudget: "",
        outZcHyBudget: "",
        outTbGjhzBudget: "",
        outZcGjhzBudget: "",
        outTbCbBudget: "",
        outZcCbBudget: "",
        outTbLwBudget: "",
        outZcLwBudget: "",
        outTbZjzxBudget: "",
        outZcZjzxBudget: "",
        outTbQtBudget: "",
        outZcQtBudget: "",
        outTbGlBudget: "",
        outZcGlBudget: "",
        tbsqyiBudget: "",
        tbsqyibl: "",
        tbsqerBudget: "",
        tbsqerbl: "",
      },
      formData5: {
        Equipments: []
      }
    }
  },
  watch: {
    activeForm: {
      immediate: true,
      handler(val) {
        const targetEle = document.getElementById("main")
        if (targetEle) {
          const {pos, top} = targetEle.style;
          targetEle.style.position = 'relative';
          targetEle.style.top = '-100px';
          targetEle.scrollIntoView({behavior: 'smooth', block: 'start', inline: "nearest"});
          targetEle.style.top = top;
          targetEle.style.position = pos;
        }
      }
    }
  },
  async created() {
    await this.getDataTypes()
    await Promise.all([this.getDeptTreeSelect(this.$store.state.user.deptId), this.getProfTitTreeSelect(),]);
    const taskId = this.$route.params && this.$route.params.taskId;
    if (!taskId) {
      this.$message.error("任务id丢失返回项目");
      this.$router.push("/tjpt/platform/platform-my");
    }
    this.taskId = taskId;
    this.$api.tjpt.project.getPlatformMemberByType(taskId, "1").then(response => {
      if (response.data !== null && response.data.length > 0) {
        sessionStorage.setItem(`${this.taskId}-platform-memberId`, taskId)
      }
    }).catch((e) => {
      this.applyLoading = false;
    });
    this.$api.tjpt.project.getAll(taskId).then(response => {
      // this.$api.tjpt.project.get(taskId).then(response => {
      if (response.data !== null) {
        response.data.projectLeader = response.data.projectLeader ? response.data.projectLeader : this.formData0.projectLeader;
        this.formData0 = response.data;
        response.data?.keyWord && (this.formData0.keyWord = response.data.keyWord?.split(",").filter(item=> item !== ''))
        sessionStorage.setItem(`${this.taskId}-platform-platformId`, taskId)
        if (response.data.constructionUnit.id) {
          sessionStorage.setItem(`${this.taskId}-platform-unitId`, response.data.constructionUnit.id)
        }
        if (response.data.platformBackground.id) {
          sessionStorage.setItem(`${this.taskId}-platform-backgroundId`, response.data.platformBackground.id)
        }
        if (response.data.platformMainTask.id) {
          sessionStorage.setItem(`${this.taskId}-platform-mainTaskId`, response.data.platformMainTask.id)
        }
        if (response.data.platformBudget.id) {
          sessionStorage.setItem(`${this.taskId}-platform-budgetId`, response.data.platformBudget.id)
        }
        if (response.data.platformEquipments.id) {
          sessionStorage.setItem(`${this.taskId}-platform-equipmentId`, response.data.platformEquipments.id)
        }
        if (response.data.platformSafeguard.id) {
          sessionStorage.setItem(`${this.taskId}-platform-safeguardId`, response.data.platformSafeguard.id)
        }
        if (response.data.sysAttMainVo?.sysAttMainIds.length >= 1) {
          sessionStorage.setItem(`${this.taskId}-platform-fileId`, JSON.stringify(response.data.sysAttMainVo))
        }
        this.applyLoading = false;
      }
      // response.data.projectLeader = response.data.projectLeader ? response.data.projectLeader : this.formData0.projectLeader;
      // this.formData0 = response.data;
      // this.formData0.keyWord = response.data.keyWord?.split(",").filter(item=> item !== '')
      const activeForm = Number(sessionStorage.getItem(`${taskId}-platform-activeForm`)) || 0;
      console.log("activeForm", activeForm)
      this.onCurChanged(activeForm, 0);
    }).catch((e) => {
      this.applyLoading = false;
      this.$message.error(e.toString());
    });
    // const activeForm = Number(sessionStorage.getItem(`${taskId}-platform-activeForm`)) || 0;
    // console.log("activeForm",activeForm)
    // this.onCurChanged(activeForm, 0);
  },
  methods: {
    getDataTypes() {
      return getDictList(["prof_tit"]).then(response => {
        this.dictTypes = response.data;
      }).catch((e) => {
        this.$message.error(e.toString());
      });
    },
    createKeyWordOptions(value) {
      this.dict.type.tjpt_key_word.push({
        label: `${value}`,
        value,
      });
    },
    createProjectLeaderOptions(value) {
      this.nameOptions.push({
        label: `${value}`,
        value,
        name: value
      });
    },
    createProjectLeaderOptions2(value) {
      this.nameOptions2.push({
        label: `${value}`,
        value,
        name: value
      });
    },
    createProjectLeaderOptions3(value) {
      this.nameOptions3.push({
        label: `${value}`,
        value,
        name: value
      });
    },
    remoteProjectLeaderMethod(search) {
      this.leaderLoading = true;
      this.$api.system.member.searchList({name: search}).then(response => {
        this.nameOptions = response.data.map(val => ({
          ...val,
          label: `${val.name}-${val.idCard}`,
          value: `${val.name}-${val.idCard}`,
        }));
        this.leaderLoading = false;
      }).catch((e) => {
        this.leaderLoading = false;
        this.$message.error(e.toString());
      });
    },
    remoteProjectLeaderMethod2(search) {
      this.leaderLoading2 = true;
      this.$api.system.member.searchList({name: search}).then(response => {
        this.nameOptions2 = response.data.map(val => ({
          ...val,
          label: `${val.name}-${val.idCard}`,
          value: `${val.name}-${val.idCard}`,
        }));
        this.leaderLoading2 = false;
      }).catch((e) => {
        this.leaderLoading2 = false;
        this.$message.error(e.toString());
      });
    },
    remoteProjectLeaderMethod3(search) {
      this.leaderLoading3 = true;
      this.$api.system.member.searchList({name: search}).then(response => {
        this.nameOptions3 = response.data.map(val => ({
          ...val,
          label: `${val.name}-${val.idCard}`,
          value: `${val.name}-${val.idCard}`,
        }));
        this.leaderLoading3 = false;
      }).catch((e) => {
        this.leaderLoading3 = false;
        this.$message.error(e.toString());
      });
    },
    onLeaderNameChange(val, content) {
      console.log("change")
      const index = this.nameOptions.findIndex(val => content?.option?.id === val.id)
      this.nameOptions[index].label = this.nameOptions[index].name;
      this.$set(this.nameOptions, index, this.nameOptions[index])
      // Object.assign(this.formData0.projectLeader, content.option)
      const oldId = this.formData0.id;
      const platformLeaderID = this.formData0.platformLeader.id
      const {telephone} = this.formData0.platformLeader
      const {phone} = this.formData0.platformLeader
      const {email} = this.formData0.platformLeader
      // this.formData0.platformLeader = content.option || this.nameOptions[index]
      const obj = {
        phone: this.formData0.platformLeader.phone,
        email: this.formData0.platformLeader.email
      }
      Object.assign(this.formData0.platformLeader, content.option || this.nameOptions[index], obj)
      this.formData0.id = oldId;
      this.formData0.platformLeader.id = platformLeaderID
      // this.formData0.platformLeader.telephone = ""
      // this.formData0.platformLeader.telephone = telephone
      // this.formData0.platformLeader.phone = phone
      // this.formData0.platformLeader.email = email
    },
    onLeaderNameChange2(val, content) {
      const index = this.nameOptions2.findIndex(val => content?.option?.id === val.id)
      this.nameOptions2[index].label = this.nameOptions2[index].name;
      this.$set(this.nameOptions2, index, this.nameOptions2[index])

      // Object.assign(this.formData0.projectLeader, content.option)
      const oldId = this.formData0.id;

      this.formData0.platformLinker = content.option || this.nameOptions2[index]
      this.formData0.id = oldId;
    },
    onLeaderNameChange3(val, content) {
      const index = this.nameOptions3.findIndex(val => content?.option?.id === val.id)
      this.nameOptions3[index].label = this.nameOptions3[index].name;
      this.$set(this.nameOptions3, index, this.nameOptions3[index])
      // Object.assign(this.formData0.projectLeader, content.option)
      const oldId = this.formData0.id;
      const obj = {
        phone: this.formData1.phone,
        email: this.formData1.email
      }
      Object.assign(this.formData1, content.option || this.nameOptions3[index], obj)
      // this.formData1 = content.option || this.nameOptions3[index]
      this.formData0.id = oldId;
    },
    onProfTitIdChange(val) {
      this.$api.system.profTit.get(val).then(response => {
        this.formData0.platformLeader.profTit = response.data.level;
      }).catch((e) => {
        this.$message.error(e.toString());
      });
    },
    onProfTitIdChange2(val) {
      this.$api.system.profTit.get(val).then(response => {
        this.formData1.profTit = response.data.level;
      }).catch((e) => {
        this.$message.error(e.toString());
      });
    },
    getProfTitTreeSelect() {
      return this.$api.system.profTit.treeselect().then(response => {
        this.profTitOptions = response.data;
      }).catch((e) => {
        this.$message.error(e.toString());
      });
    },
    getDeptTreeSelect() {
      return this.$api.system.dept.treeSelectAllIn().then(response => {
        this.deptMenuOptions = response.data;
      }).catch((e) => {
        this.$message.error(e.toString());
      });
    },
    close() {
      this.applyLoading = false;
      setTimeout(() => {
        this.$tab.closeOpenPage({path: "/tjpt/platform/project-my"});
      }, 1000)
    },
    onCurChanged(cur, pre) {
      console.log(cur)
      if (Number(cur) === 1) {
        // if (!sessionStorage.getItem(`${this.taskId}-platformId`) && !sessionStorage.getItem(`${this.taskId}-unitId`)) {
        if (!sessionStorage.getItem(`${this.taskId}-platform-platformId`)) {
          this.$message.error("基本信息还未提交")
          return false;
        }
      } else if (Number(cur) === 2) {
        if (!sessionStorage.getItem(`${this.taskId}-platform-unitId`) && !sessionStorage.getItem(`${this.taskId}-platform-backgroundId`)) {
          this.$message.error("建设单位信息还未提交")
          return false;
        }
      } else if (Number(cur) === 3) {
        if (!sessionStorage.getItem(`${this.taskId}-platform-backgroundId`) && !sessionStorage.getItem(`${this.taskId}-platform-mainTaskId`)) {
          this.$message.error("立项背景与意义信息还未提交");
          return false;
        }
      } else if (Number(cur) === 4) {
        if (!sessionStorage.getItem(`${this.taskId}-platform-mainTaskId`) && !sessionStorage.getItem(`${this.taskId}-platform-budgetId`)) {
          this.$message.error("主要任务信息还未提交");
          return false;
        }
      } else if (Number(cur) === 5) {
        if (!sessionStorage.getItem(`${this.taskId}-platform-budgetId`) && !sessionStorage.getItem(`${this.taskId}-platform-equipmentId`)) {
          this.$message.error("经费预算信息还未提交");
          return false;
        }
      } else if (Number(cur) === 6) {
        if (!sessionStorage.getItem(`${this.taskId}-platform-equipmentId`) && !sessionStorage.getItem(`${this.taskId}-platform-memberId`)) {
          this.$message.error("仪器设备经费概算信息还未提交");
          return false;
        }
      } else if (Number(cur) === 7) {
        if (!sessionStorage.getItem(`${this.taskId}-platform-memberId`) && !sessionStorage.getItem(`${this.taskId}-platform-safeguardId`)) {
          this.$message.error("委员会人员信息还未提交");
          return false;
        }
      } else if (Number(cur) === 8) {
        if (!sessionStorage.getItem(`${this.taskId}-platform-safeguardId`) && !sessionStorage.getItem(`${this.taskId}-platform-fileId`)) {
          this.$message.error("建设单位的保障条件与经费配套信息还未提交");
          return false;
        }
      }
      this.applyLoading = true;
      if (Number(cur) === 0) {
        if (sessionStorage.getItem(`${this.taskId}-platform-platformId`)) {
          const platformId = Number(sessionStorage.getItem(`${this.taskId}-platform-platformId`));
          this.$api.tjpt.project.get(platformId).then(response => {
            response.data.projectLeader = response.data.projectLeader ? response.data.projectLeader : this.formData0.projectLeader;
            this.formData0 = response.data;
            response.data?.keyWord && (this.formData0.keyWord = response.data.keyWord?.split(",").filter(item=> item !== ''))
            this.activeForm = cur;
            sessionStorage.setItem(`${this.taskId}-platform-activeForm`, cur);
            this.applyLoading = false;
          }).catch((e) => {
            this.applyLoading = false;
            this.$message.error(e.toString());
          });
        } else {
          this.activeForm = cur;
          sessionStorage.setItem(`${this.taskId}-platform-activeForm`, cur);
          this.applyLoading = false;
        }

      } else if (Number(cur) === 1) {
        if (sessionStorage.getItem(`${this.taskId}-platform-unitId`)) {
          const unitId = Number(sessionStorage.getItem(`${this.taskId}-platform-unitId`));
          this.$api.tjpt.project.constructionUnitDetail(unitId).then(response => {
            this.formData1 = response.data;
            this.activeForm = cur;
            sessionStorage.setItem(`${this.taskId}-platform-activeForm`, cur);
            this.applyLoading = false;
          }).catch((e) => {
            this.applyLoading = false;
            this.$message.error(e.toString());
          });
        } else {
          this.activeForm = cur;
          sessionStorage.setItem(`${this.taskId}-platform-activeForm`, cur);
          this.applyLoading = false;
        }
      } else if (Number(cur) === 2) {
        if (sessionStorage.getItem(`${this.taskId}-platform-backgroundId`)) {
          const backgroundId = Number(sessionStorage.getItem(`${this.taskId}-platform-backgroundId`));
          this.$api.tjpt.project.platformBackgroundDetail(backgroundId).then(response => {
            this.formData2 = response.data;
            this.activeForm = cur;
            sessionStorage.setItem(`${this.taskId}-platform-activeForm`, cur);
            this.applyLoading = false;
          }).catch((e) => {
            this.applyLoading = false;
            this.$message.error(e.toString());
          });
        } else {
          this.activeForm = cur;
          sessionStorage.setItem(`${this.taskId}-platform-activeForm`, cur);
          this.applyLoading = false;
        }
      } else if (Number(cur) === 3) {
        if (sessionStorage.getItem(`${this.taskId}-platform-mainTaskId`)) {
          const mainTaskId = Number(sessionStorage.getItem(`${this.taskId}-platform-mainTaskId`));
          this.$api.tjpt.project.platformMainTaskDetail(mainTaskId).then(response => {
            this.formData3 = response.data;
            this.activeForm = cur;
            sessionStorage.setItem(`${this.taskId}-platform-activeForm`, cur);
            this.applyLoading = false;
          }).catch((e) => {
            this.applyLoading = false;
            this.$message.error(e.toString());
          });
        } else {
          this.activeForm = cur;
          sessionStorage.setItem(`${this.taskId}-platform-activeForm`, cur);
          this.applyLoading = false;
        }
      } else if (Number(cur) === 4) {
        if (sessionStorage.getItem(`${this.taskId}-platform-budgetId`)) {
          const budgetId = Number(sessionStorage.getItem(`${this.taskId}-platform-budgetId`));
          this.$api.tjpt.project.platformBudgetDetail(budgetId).then(response => {
            this.formData4 = response.data;
            this.activeForm = cur;
            sessionStorage.setItem(`${this.taskId}-platform-activeForm`, cur);
            this.applyLoading = false;
          }).catch((e) => {
            this.applyLoading = false;
            this.$message.error(e.toString());
          });
        } else {
          this.activeForm = cur;
          sessionStorage.setItem(`${this.taskId}-platform-activeForm`, cur);
          this.applyLoading = false;
        }
      } else if (Number(cur) === 5) {
        if (sessionStorage.getItem(`${this.taskId}-platform-equipmentId`)) {
          const equipmentId = Number(sessionStorage.getItem(`${this.taskId}-platform-equipmentId`));
          this.$api.tjpt.project.getByPlatformId(equipmentId).then(response => {
            this.formData5.Equipments = response.data;
            this.activeForm = cur;
            sessionStorage.setItem(`${this.taskId}-platform-activeForm`, cur);
            this.applyLoading = false;
          }).catch((e) => {
            this.applyLoading = false;
            this.$message.error(e.toString());
          });
        } else {
          this.activeForm = cur;
          sessionStorage.setItem(`${this.taskId}-platform-activeForm`, cur);
          this.applyLoading = false;
        }
      } else if (Number(cur) === 6) {
        if (sessionStorage.getItem(`${this.taskId}-platform-memberId`)) {
          const memberId = Number(sessionStorage.getItem(`${this.taskId}-platform-memberId`));
          this.$api.tjpt.project.getPlatformMemberByType(memberId, "1").then(response => {
            this.formData8.platformMember = response.data
            // this.formData5.Equipments = response.data;
            this.activeForm = cur;
            // sessionStorage.setItem(`${this.taskId}-platform-activeForm`, cur);
            this.applyLoading = false;
          }).catch((e) => {
            this.applyLoading = false;
            this.$message.error(e.toString());
          });
          this.$api.tjpt.project.getPlatformMemberByType(memberId, "2").then(response => {
            this.formData8.platformMemberTechnology = response.data
            // this.formData5.Equipments = response.data;
            // this.activeForm = cur;
            // sessionStorage.setItem(`${this.taskId}-platform-activeForm`, cur);
            this.applyLoading = false;
          }).catch((e) => {
            this.applyLoading = false;
            this.$message.error(e.toString());
          });
        } else {
          this.activeForm = cur;
          sessionStorage.setItem(`${this.taskId}-platform-activeForm`, cur);
          this.applyLoading = false;
        }
      } else if (Number(cur) === 7) {
        if (sessionStorage.getItem(`${this.taskId}-platform-safeguardId`)) {
          const safeguardId = Number(sessionStorage.getItem(`${this.taskId}-platform-safeguardId`));
          this.$api.tjpt.project.platformSafeguardDetail(safeguardId).then(response => {
            this.formData7 = response.data;
            this.activeForm = cur;
            sessionStorage.setItem(`${this.taskId}-platform-activeForm`, cur);
            this.applyLoading = false;
          }).catch((e) => {
            this.applyLoading = false;
            this.$message.error(e.toString());
          });
        } else {
          this.activeForm = cur;
          sessionStorage.setItem(`${this.taskId}-platform-activeForm`, cur);
          this.applyLoading = false;
        }
      } else if (Number(cur) === 8) {
        if (sessionStorage.getItem(`${this.taskId}-platform-fileId`)) {
          getFiles(this.getPlatformId()).then((res) => {
            this.activeForm = cur;
            const files = {}
            res.data.forEach((item) => {
              if (!files[item.moduleKey]) {
                files[item.moduleKey] = []
              }
              files[item.moduleKey].push({
                name: item.fileName,
                url: item.fullFilePath,
                id: item.id,
                filePath: item.filePath
              })
            })
            this.projectFileData[0].fileLists = files.platformPFWJ || [];
            this.projectFileData[0].fileIds = files.platformPFWJ?.map(val => val.id) || [];
          }).catch((e) => {
            this.applyLoading = false;
            this.$message.error(e.toString());
          });
          this.applyLoading = false;
        } else {
          this.activeForm = cur;
          sessionStorage.setItem(`${this.taskId}-platform-activeForm`, cur);
          this.applyLoading = false;
        }
      } else {
        this.activeForm = cur;
        sessionStorage.setItem(`${this.taskId}-platform-activeForm`, cur);
        this.applyLoading = false;
      }
    },
    getPlatformId() {
      return sessionStorage.getItem(`${this.taskId}-platform-platformId`)
    },
    isSubmit(name) {
      console.log(sessionStorage.getItem(`${this.taskId}-platform-memberId`))
      return sessionStorage.getItem(`${this.taskId}-platform-${name}`) ? '已提交' : '未提交';
    },
    onSubmit0({validateResult, firstError}) {
      if (validateResult === true) {
        this.applyLoading = true;
        this.formData0.keyWord = this.formData0?.keyWord?.join(",")
        if (!sessionStorage.getItem(`${this.taskId}-platform-platformId`)) {
          this.$api.tjpt.project.add({
            ...this.formData0,
            platformStatus: '1',
          }).then(response => {
            sessionStorage.setItem(`${this.taskId}-platform-platformId`, response.data.id)
            this.$message.success('提交成功');
            this.onCurChanged(1)
          }).catch((e) => {
            this.applyLoading = false;
            this.$message.error(e.toString());
          });
        } else {
          this.$api.tjpt.project.edit({
            ...this.formData0,
            platformStatus: '1',
          }).then(response => {
            this.$message.success('修改成功');
            this.onCurChanged(1)
          }).catch((e) => {
            this.applyLoading = false;
            this.$message.error(e.toString());
          });
        }
      } else {
        this.$message.error(firstError);
      }
    },
    onSubmit1({validateResult, firstError}) {
      if (validateResult === true) {
        this.applyLoading = true;
        this.formData1.platformId = Number(sessionStorage.getItem(`${this.taskId}-platform-platformId`));
        delete this.formData1.id
        if (!sessionStorage.getItem(`${this.taskId}-platform-unitId`)) {
          this.$api.tjpt.project.constructionUnitAdd(this.formData1).then(response => {
            sessionStorage.setItem(`${this.taskId}-platform-unitId`, response.data.id)
            this.$message.success('提交成功');
            this.onCurChanged(2);
          }).catch((e) => {
            this.applyLoading = false;
            this.$message.error(e.toString());
          });
        } else {
          this.$api.tjpt.project.constructionUnitUpdate({
            ...this.formData1,
            id: Number(sessionStorage.getItem(`${this.taskId}-platform-unitId`))
          }).then(response => {
            this.$message.success('提交成功');
            this.onCurChanged(2);
          }).catch((e) => {
            this.applyLoading = false;
            this.$message.error(e.toString());
          });
        }

      } else {
        this.$message.error(firstError);
      }
    },
    onSubmit2({validateResult, firstError}) {
      if (validateResult === true) {
        this.applyLoading = true;
        if (this.lengthLimitObj.background > 2000) {
          this.$message.error(`立项背景与意义 当前字数${this.lengthLimitObj.researchContent}，限制字数2000`)
          return false;
        }
        this.formData2.platformId = Number(sessionStorage.getItem(`${this.taskId}-platform-platformId`));
        if (!sessionStorage.getItem(`${this.taskId}-platform-backgroundId`)) {
          this.$api.tjpt.project.platformBackgroundAdd({
            ...this.formData2,
          }).then(response => {
            sessionStorage.setItem(`${this.taskId}-platform-backgroundId`, response.data.id);
            this.$message.success('提交成功');
            this.onCurChanged(3);
          }).catch((e) => {
            this.applyLoading = false;
            this.$message.error(e.toString());
          });
        } else {
          this.$api.tjpt.project.platformBackgroundUpdate({
            ...this.formData2,
            id: Number(sessionStorage.getItem(`${this.taskId}-platform-backgroundId`))
          }).then(response => {
            this.$message.success('提交成功');
            this.onCurChanged(3);
          }).catch((e) => {
            this.applyLoading = false;
            this.$message.error(e.toString());
          });
        }
      } else {
        this.$message.error(firstError);
      }
    },
    onSubmit3({validateResult, firstError}) {
      if (validateResult === true) {
        if (this.lengthLimitObj.mainTask > this.maxlength) {
          this.$message.error(`主要任务信息 当前字数：${this.lengthLimitObj.achievement}，限制字数：${this.maxlength}`)
          return false;
        }
        this.formData3.platformId = Number(sessionStorage.getItem(`${this.taskId}-platform-platformId`));
        this.applyLoading = true;
        if (!sessionStorage.getItem(`${this.taskId}-platform-mainTaskId`)) {
          this.$api.tjpt.project.platformMainTaskAdd(this.formData3).then(response => {
            sessionStorage.setItem(`${this.taskId}-platform-mainTaskId`, response.data.id)
            this.$message.success('提交成功');
            this.onCurChanged(4);
          }).catch((e) => {
            this.applyLoading = false;
            this.$message.error(e.toString());
          });
        } else {
          this.$api.tjpt.project.platformMainTaskUpdate({
            ...this.formData3,
            id: Number(sessionStorage.getItem(`${this.taskId}-platform-mainTaskId`))
          }).then(response => {
            this.$message.success('提交成功');
            this.onCurChanged(4);
          }).catch((e) => {
            this.applyLoading = false;
            this.$message.error(e.toString());
          });
        }
      } else {
        this.$message.error(firstError);
      }
    },
    onSubmit4() {
      // 判断经费来源 经费支出 是否一致
      const sum1 = (Number(this.formData4.inTbBudget || 0) * 100 + Number(this.formData4.inZcBudget || 0) * 100) / 100
      const sum2 = Number((Number(this.formData4.outTbSbBudget || 0) * 100 + Number(this.formData4.outTbSzsbBudget || 0) * 100 + Number(this.formData4.outTbSbzzBudget || 0) * 100 +
        Number(this.formData4.outTbClBudget || 0) * 100 + Number(this.formData4.outTbSyjgBudget || 0) * 100 + Number(this.formData4.outTbRldlBudget || 0) * 100 + Number(this.formData4.outTbClvBudget || 0) * 100 + Number(this.formData4.outTbHyBudget || 0) * 100 + Number(this.formData4.outTbGjhzBudget || 0) * 100 + Number(this.formData4.outTbCbBudget || 0) * 100 + Number(this.formData4.outTbLwBudget || 0) * 100 + Number(this.formData4.outTbZjzxBudget || 0) * 100 + Number(this.formData4.outTbQtBudget || 0) * 100 + Number(this.formData4.outTbGlBudget || 0) * 100 + Number(this.formData4.outTbJxzcBudget || 0) * 100 + Number(this.formData4.outZcSbBudget || 0) * 100 + Number(this.formData4.outZcSzsbBudget || 0) * 100 + Number(this.formData4.outZcSbzzBudget || 0) * 100 + Number(this.formData4.outZcClBudget || 0) * 100 + Number(this.formData4.outZcSyjgBudget || 0) * 100 + Number(this.formData4.outZcRldlBudget || 0) * 100 + Number(this.formData4.outZcClvBudget || 0) * 100 + Number(this.formData4.outZcHyBudget || 0) * 100 + Number(this.formData4.outZcGjhzBudget || 0) * 100 + Number(this.formData4.outZcCbBudget || 0) * 100 + Number(this.formData4.outZcLwBudget || 0) * 100 + Number(this.formData4.outZcZjzxBudget || 0) * 100 + Number(this.formData4.outZcQtBudget || 0) * 100 + Number(this.formData4.outZcGlBudget || 0) * 100 + Number(this.formData4.outZcJxzcBudget || 0) * 100)) / 100
      console.log(this.formData4)
      console.log(sum1, sum2)
      if (sum1 !== sum2) {
        this.$message.error('经费来源 与 经费支出 金额不一致');
        return false;
      }
      this.applyLoading = true;
      this.formData4.platformId = Number(sessionStorage.getItem(`${this.taskId}-platform-platformId`));
      if (!sessionStorage.getItem(`${this.taskId}-platform-budgetId`)) {
        this.$api.tjpt.project.platformBudgetAdd(this.formData4).then(response => {
          sessionStorage.setItem(`${this.taskId}-platform-budgetId`, response.data.id)
          this.$message.success('提交成功');
          this.onCurChanged(5);
        }).catch((e) => {
          this.applyLoading = false;
          this.$message.error(e.toString());
        });
      } else {
        this.$api.tjpt.project.platformBudgetUpdate({
          ...this.formData4,
          id: Number(sessionStorage.getItem(`${this.taskId}-platform-budgetId`))
        }).then(response => {
          this.$message.success('提交成功');
          this.onCurChanged(5);
        }).catch((e) => {
          this.applyLoading = false;
          this.$message.error(e.toString());
        });
      }
    },
    onSubmit5({validateResult, firstError}) {
      if (validateResult === true) {
        const isValidate = this.$refs["project-background-literature"].checkData();
        if (!isValidate) {
          return false;
        }
        for (let i = 0; i < this.formData5.Equipments.length; i++) {
          this.formData5.Equipments[i].platformId = Number(sessionStorage.getItem(`${this.taskId}-platform-platformId`));
        }
        this.applyLoading = true;
        if (!sessionStorage.getItem(`${this.taskId}-platform-equipmentId`)) {
          this.$api.tjpt.project.platformEquipmentAddList(this.formData5.Equipments).then(response => {
            sessionStorage.setItem(`${this.taskId}-platform-equipmentId`, Number(sessionStorage.getItem(`${this.taskId}-platform-platformId`)))
            this.$message.success('提交成功');
            this.onCurChanged(6);
          }).catch((e) => {
            this.applyLoading = false;
            this.$message.error(e.toString());
          });
        } else {
          this.$api.tjpt.project.platformEquipmentAddList(this.formData5.Equipments).then(response => {
            this.$message.success('提交成功');
            this.onCurChanged(6);
          }).catch((e) => {
            this.applyLoading = false;
            this.$message.error(e.toString());
          });
        }

      } else {
        this.$message.error(firstError);
      }
    },
    onSubmit7(type) {
      if (type === 1) {
        this.applyLoading = true;
        this.$refs.form.validate().then((validateResult) => {
          if (validateResult === true) {
            if (!sessionStorage.getItem(`${this.taskId}-platform-safeguardId`)) {
              this.formData7.platformId = this.getPlatformId()
              this.$api.tjpt.project.platformSafeguardAdd({
                ...this.formData7,
              }).then(response => {
                sessionStorage.setItem(`${this.taskId}-platform-safeguardId`, response.data.id);
                this.$message.success('提交成功');
                this.onCurChanged(8);
                // this.close();
              }).catch((e) => {
                this.applyLoading = false;
                this.$message.error(e.toString());
              });
            } else {
              this.$api.tjpt.project.platformSafeguardUpdate({
                ...this.formData7,
                id: Number(sessionStorage.getItem(`${this.taskId}-platform-safeguardId`))
              }).then(response => {
                this.$message.success('提交成功');
                this.onCurChanged(8);
                // this.close();
              }).catch((e) => {
                this.applyLoading = false;
                this.$message.error(e.toString());
              });
            }
          } else {
            this.applyLoading = false;
            const firstError = Object.values(validateResult)[0]?.[0]?.message;
            this.$message.error(firstError);
          }
        })
      }
      // else {
      //   this.$refs.form.validate().then((validateResult) => {
      //     if (validateResult === true) {
      //       if (!sessionStorage.getItem(`${this.taskId}-platform-safeguardId`)) {
      //         this.$api.tjpt.project.platformSafeguardAdd({
      //           ...this.formData7,
      //         }).then(response => {
      //           sessionStorage.setItem(`${this.taskId}-platform-safeguardId`, response.data.id);
      //           this.$message.success('提交成功');
      //           this.applyLoading = false;
      //           this.isCommit = false;
      //           this.onCurChanged(8);
      //           // this.close();
      //           // this.$api.tjpt.project.submit({
      //           //   id: Number(sessionStorage.getItem(`${this.taskId}-platform-platformId`)),
      //           // }).then(val => {
      //           //   sessionStorage.setItem(`${this.taskId}-platform-safeguardId`, response.data.id);
      //           //   this.$message.success('提交成功');
      //           //   this.applyLoading = false;
      //           //   this.isCommit = false;
      //           //   this.close();
      //           // }).catch((e) => {
      //           //   this.applyLoading = false;
      //           //   this.isCommit = false;
      //           //   this.$message.error(e.toString());
      //           // });
      //         }).catch((e) => {
      //           this.applyLoading = false;
      //           this.$message.error(e.toString());
      //         });
      //       } else {
      //         this.$api.tjpt.project.platformSafeguardUpdate({
      //           ...this.formData7,
      //           id: Number(sessionStorage.getItem(`${this.taskId}-platform-safeguardId`))
      //         }).then(response => {
      //           this.$api.tjpt.project.submit({
      //             id: Number(sessionStorage.getItem(`${this.taskId}-platform-platformId`)),
      //           }).then(val => {
      //             this.$message.success('提交成功');
      //             this.applyLoading = false;
      //             this.isCommit = false;
      //             this.close();
      //           }).catch((e) => {
      //             this.applyLoading = false;
      //             this.isCommit = false;
      //             this.$message.error(e.toString());
      //           });
      //         }).catch((e) => {
      //           this.applyLoading = false;
      //           this.$message.error(e.toString());
      //         });
      //       }
      //     } else {
      //       const firstError = Object.values(validateResult)[0]?.[0]?.message;
      //       this.$message.error(firstError);
      //     }
      //   });
      // }
      // if (validateResult === true) {
      //   if (this.lengthLimitObj.safeguardCondition > 2000) {
      //     this.$message.error(`建设单位的保障条件与经费配套信息,当前字数：${this.lengthLimitObj.safeguardCondition}，限制字数：2000`)
      //     return false;
      //   }
      //   this.applyLoading = true;
      //   if (!sessionStorage.getItem(`${this.taskId}-platform-safeguardId`)) {
      //     this.$api.tjpt.project.platformSafeguardAdd({
      //       ...this.formData7,
      //     }).then(response => {
      //       sessionStorage.setItem(`${this.taskId}-platform-safeguardId`, response.data.id);
      //       this.$message.success('提交成功');
      //       this.onCurChanged(6);
      //     }).catch((e) => {
      //       this.applyLoading = false;
      //       this.$message.error(e.toString());
      //     });
      //   } else {
      //     this.$api.tjpt.project.platformSafeguardUpdate({
      //       ...this.formData7,
      //       id: Number(sessionStorage.getItem(`${this.taskId}-platform-safeguardId`))
      //     }).then(response => {
      //       this.next4();
      //     }).catch((e) => {
      //       this.applyLoading = false;
      //       this.$message.error(e.toString());
      //     });
      //   }
      // } else {
      //   this.$message.error(firstError);
      // }
    },
    onSubmit8({validateResult, firstError}) {
      if (validateResult === true) {
        const isValidate = this.$refs["platform-member"].checkData();
        const isValidate2 = this.$refs["platform-member-technology"].checkData();
        if (!isValidate || !isValidate2) {
          return false;
        }
        this.formData8.platformMember.forEach(item => {
          item.type = "1"
          item.platformId = Number(sessionStorage.getItem(`${this.taskId}-platform-platformId`));
        })
        this.formData8.platformMemberTechnology.forEach(item => {
          item.type = "2"
          item.platformId = Number(sessionStorage.getItem(`${this.taskId}-platform-platformId`));
        })
        // 增加note字段
        for (const item in this.formData8) {
          this.formData8[item].forEach((i, index) => {
            if (!i.hasOwnProperty("note")) {
              this.formData8[item][index].note = ""
            }
          })
        }
        let subArr = []
        subArr = [...this.formData8.platformMember, ...this.formData8.platformMemberTechnology]
        this.applyLoading = true;
        this.$api.tjpt.project.platformMemberAdd(subArr).then(response => {
          this.applyLoading = false;
          sessionStorage.setItem(`${this.taskId}-platform-memberId`, Number(sessionStorage.getItem(`${this.taskId}-platform-platformId`)))
          this.$message.success('提交成功');
          this.onCurChanged(7);
        }).catch((e) => {
          this.applyLoading = false;
          this.$message.error(e.toString());
        });
        // if (!sessionStorage.getItem(`${this.taskId}-platform-equipmentId`)) {
        //   this.$api.tjpt.project.platformEquipmentAddList(this.formData5.Equipments).then(response => {
        //     sessionStorage.setItem(`${this.taskId}-platform-equipmentId`, Number(sessionStorage.getItem(`${this.taskId}-platform-platformId`)))
        //     this.$message.success('提交成功');
        //     this.onCurChanged(6);
        //   }).catch((e) => {
        //     this.applyLoading = false;
        //     this.$message.error(e.toString());
        //   });
        // } else {
        //   this.$api.tjpt.project.platformEquipmentAddList(this.formData5.Equipments).then(response => {
        //     this.$message.success('提交成功');
        //     this.onCurChanged(6);
        //   }).catch((e) => {
        //     this.applyLoading = false;
        //     this.$message.error(e.toString());
        //   });
        // }

      } else {
        this.$message.error(firstError);
      }
    }
    ,
    onSubmit9() {
      const platformId = this.getPlatformId()
      const sysAttMainVo = {
        sysAttMainIds: this.projectFileData[0].fileIds,
      }
      if(this.formData0.keyWord instanceof Array){
        this.formData0.keyWord = this.formData0?.keyWord?.join(",")
      }
      this.$api.tjpt.project.edit({
        ...this.formData0,
        platformStatus: "1",
        id: platformId,
        sysAttMainVo
      }).then(val => {
        sessionStorage.setItem(`${this.taskId}-platform-fileId`, JSON.stringify(sysAttMainVo));
        this.$message.success('提交成功');
        this.applyLoading = false;
        this.close();
      }).catch((e) => {
        this.applyLoading = false;
        this.$message.error(e.toString());
      });
    }
  }
}
</script>

<style lang="less" scoped>
.step-form {
  padding: 0 24px;
}

.t-row {
  margin-bottom: 14px;
}

.step-card {
  height: 100%;
  margin-bottom: 14px;
}
</style>
